<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>17题判断闰年</title>
    <script>
        function caculate(flag) {
            var year = prompt(flag ? '请输入正确的年份' : '请输入一个年份数');
            if (!/^[0-9]*$/i.test(year)) {
                caculate(true);
                return;
            }
            
            let rs = year % 100;
            let ops = 0;
            // 非整百年份
            if (rs > 0) {
                ops = 4;
            } else {
                ops = 400;
            }

            let result = year % ops;
            if (result > 0) {
                alert(`您好，${year}年不是闰年`);
            } else {
                alert(`您好，${year}年是闰年`);
            }
        }
    </script>
</head>
<body>
    <p>
        点击按钮开始输入<input type="button" value="点击输入" onclick="caculate()">
    </p>
</body>
</html>